<div class="centered">

<?php 
$last_round = -1;
$cs = "5";
$ref_id = 0;

function get_name($id)
{
	global $pdict;
	$p = $pdict[$id];
	return $p->surname . "&nbsp;" . $p->name;
}

function get_rating($id)
{
	global $pdict;
	$p = $pdict[$id];
	if ($p->rating < 0)
		return "&nbsp;";
	return floor($p->rating);
}

function get_result(&$log)
{
	$br = $log->actual_score;
	if ($br == 0)
		return "0 : 1";
	elseif ($br == 1)
		return "1 : 0";
	return "0.5 : 0.5";	
}

?>

<div id="tournament_name">
<?php echo $tournament->tournament_name?>
</div>

<table class="bigtable">
<?php foreach ($glog as $log){?>
<tr>
	<?php if ($log->round_key != $last_round) {?>
	
		<?php if ($last_round != -1) {?>
			<td class="sep" colspan="<?php echo $cs?>">&nbsp;</td></tr><tr>
		<?php }?>
		<th class="ui-widget-header round_header" colspan="<?php echo $cs?>">Round: <?php echo $log->round;?></th>
		<?php  $last_round = $log->round_key ?>
		</tr><tr>
	<?php }//if?>
	<td><?php echo get_rating($log->player_id)?></td>
	<td>
		<a onmouseover='get_score(<?php ++$ref_id; echo "$ref_id, $log->player_id, $log->opponent_id" ?>)'
		id="t<?php echo $ref_id?>" 
		class="smalllink2 qtip" href="player.php?id=<?php echo $log->player_id ?>"><?php echo get_name($log->player_id)?></a>
	</td>
	<td><?php echo get_result($log)?></td>
	<td>
		<a onmouseover='get_score(<?php ++$ref_id; echo "$ref_id, $log->opponent_id, $log->player_id" ?>)'
		id="t<?php echo $ref_id?>" 
		class="smalllink2 qtip" href="player.php?id=<?php echo $log->opponent_id ?>"><?php echo get_name($log->opponent_id)?></a>
	</td>
	<td><?php echo get_rating($log->opponent_id)?></td>
</tr>
<?php } //for?>
</table>

</div>

<script type="text/javascript">
init_tooltip();
</script>
